<template>

  <div>
    <el-alert
        v-if="paperList.length === 0"
        title="暂无考试记录"
        :closable="false"
        type="warning">
      </el-alert>

    <el-card v-for="item in paperList" style="margin-bottom: 10px; line-height: 30px;">


      <el-row :gutter="20">
        <el-col :span="12">
          姓名：{{ item.realName }}
        </el-col>

        <el-col :span="12">
          考试名称：{{ item.title }}
        </el-col>

        <el-col :span="12">
          考试结果：{{ item.passed ? '合格' : '不合格' }}
        </el-col>

        <el-col :span="12">
          考试得分：{{ item.maxScore }}
        </el-col>

        <el-col :span="12">
          考试次数：{{ item.tryCount }}
        </el-col>
      </el-row>

    </el-card>

  </div>

</template>

<script>

import { myApplyRe } from '@/api/paper/paper'

export default {

  name: 'UserPaperList',
  props: {
    applyId: {
      type: Number,
    },
    examId: {
      type: String,
      default: ''
    },
  },

  data() {
    return {
      value1: null,
      paperList: []
    }
  },

  watch: {
    // 检测查询变化
    applyId: {
      handler() {
        this.fetchPaperList()
      },
      deep: true
    },
    examId: {
      handler() {
        this.fetchPaperList()
      },
      deep: true
    }
  },

  created() {
    this.fetchPaperList()
  },
  methods: {

    fetchPaperList() {
      myApplyRe({
        applyId: this.applyId,
        examId: this.examId
      }).then(response => {
        this.paperList = response.data
      })
    }
  }
}
</script>
